<?php

namespace App\Http\Controllers\Dash;

use App\Http\Controllers\Controller;
use App\Model\Termos;
use Illuminate\Http\Request;

class TermoController extends Controller
{
    public function index()
    {
        $data = Termos::all();
        return view('dash.termo.index', compact('data'));
    }
    public function create()
    {
        return view('dash.termo.create');
    }

    public function edit($id)
    {
        $data = Termos::find($id);
        return view('dash.termo.edit', compact('data', 'id'));
    }


    public function store(Request $request)
    {
        $re = new Termos();
        $re->title = $request->title;
        $re->text = $request->text;
        $re->save();
        return redirect(route('dash.termo'));
    }

    public function update($id, Request $request)
    {
        $re = Termos::find($id);
        $re->title = $request->title;
        $re->text = $request->text;
        $re->save();
        return redirect(route('dash.termo'));
    }

    public function delete($id)
    {
        $re = Termos::find($id)->delete();
        return redirect(route('dash.termo'))->with('success', $re);
    }

}
